//
//  ShowImgView.m
//  Btpin
//
//  Created by Vic on 2019/5/5.
//  Copyright © 2019 Vic. All rights reserved.
//

#import "ShowImgView.h"

@interface ShowImgView ()
{
    UIImageView *imgView;
}
@end

@implementation ShowImgView

- (instancetype)initWithTarget:(id)target {
    self = [super init];
    if (self) {
        [self initUI];
        self.delegate = target;
    }
    return self;
}
- (void)initUI {
    self.frame = CGRectMake(0, 0, WIDTH, HEIGHT);
    self.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.9];
    [self addTarget:self action:@selector(cancelBtnTap) forControlEvents:UIControlEventTouchUpInside];
    [[UIApplication sharedApplication].keyWindow addSubview:self];
    
    CGFloat imgY = (HEIGHT-SIMEmojKeyBoardkBottomNOSafeArea_Height-WIDTH)*0.5;
    imgView = [UIToolsControl initImageViewWithFrame:CGRectMake(0, imgY, WIDTH, WIDTH) imageName:nil];
    imgView.contentMode = UIViewContentModeScaleAspectFill;
    imgView.userInteractionEnabled = NO;
    [self addSubview:imgView];
}
- (void)cancelBtnTap {
    if (self.delegate && [self.delegate respondsToSelector:@selector(showImgViewCancel:)]) {
        [self.delegate showImgViewCancel:self];
    }
}
- (void)reloadDataForImg:(NSString *)imgUrl {
    [imgView sd_setImageWithURL:[NSURL URLWithString:imgUrl]];
}

@end
